package com.gorkr.bit;

import org.junit.jupiter.api.Test;

/**
 * @author gorkr
 * @date 2022/07/27 17:12
 **/
public class E191NumberOf1Bits {
    public int hammingWeight(int n) {

        int sum = 0;
        while (n!=0){
            n = n&(n-1);
            ++sum;
        }
        return sum;
    }

    @Test
    public void test(){
        System.out.println(hammingWeight(3));
    }

}
    